package com.ynunicom.dc.dingdingcontractapp.controller;

import com.alibaba.fastjson.JSONObject;
import com.ynunicom.dc.dingdingcontractapp.dto.ResponseDto;
import com.ynunicom.dc.dingdingcontractapp.entity.StandReturnerImpl;
import com.ynunicom.dc.dingdingcontractapp.entity.requestbodyentity.TransBody;
import com.ynunicom.dc.dingdingcontractapp.service.AdminOptionService;
import com.ynunicom.dc.dingdingcontractapp.service.impl.AdminOptionServiceImpl;
import lombok.SneakyThrows;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author: jinye.Bai
 * @date: 2020/5/25 17:42
 */
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Resource
    AdminOptionService adminOptionService;

    private static Class<?> adminOptionServiceClass = AdminOptionServiceImpl.class;

    @SneakyThrows
    @ResponseStatus(HttpStatus.ACCEPTED)
    @GetMapping("/get")
    public ResponseDto<JSONObject> getAdminList(@RequestParam(value = "access_token",required = true) String access_token){
        TransBody transBody = new TransBody(null,access_token);
        return new StandReturnerImpl().doReturn(transBody,adminOptionServiceClass,adminOptionServiceClass.getMethod("getAdminList",TransBody.class));
    }

    /**
     * 获取管理员通讯录权限范围
     * @return
     */
    @SneakyThrows
    @ResponseStatus(HttpStatus.ACCEPTED)
    @GetMapping("/getScope/{userId}")
    public ResponseDto<JSONObject> getAdminScope(@PathVariable("userId") String userId,@RequestParam(value = "access_token",required = true) String access_token){
        TransBody<String> transBody = new TransBody<>(userId,access_token);
        return new StandReturnerImpl().doReturn(transBody,adminOptionServiceClass,adminOptionServiceClass.getMethod("getAdminScope",TransBody.class));

    }
}
